package top.revery.datasource.service;

import org.springframework.web.bind.annotation.RestController;
import top.revery.api.api.webPages.IWebPages;
import top.revery.api.entity.other.BaseWebPages;
import top.revery.datasource.util.dsource;

import java.util.List;
import java.util.Optional;

/**
 * <h1> --- web单页面 --- </h1>
 * Created by  revery.top jun
 * Date  2020年01月16日
 */
@RestController
public class WebPagesServiceController implements IWebPages {

    @Override
    public BaseWebPages getWebPage(Long id) {
        Optional<BaseWebPages> optional = dsource.webPagesDto.findById((long)id);
        if(optional.isPresent()){
            return optional.get();
        }
        return null;
    }

    @Override
    public List<BaseWebPages> getList() {
        List<BaseWebPages> list = dsource.webPagesDto.findAll();
        return list;
    }

    @Override
    public BaseWebPages save(BaseWebPages webPage){
        BaseWebPages baseWebPages = dsource.webPagesDto.save(webPage);
        return baseWebPages;
    }

    @Override
    public void del(int id) {
        dsource.webPagesDto.deleteById((long)id);
    }
}
